from django.db import models
# Create your models here.

class ProvinceModel(models.Model):
    name = models.CharField(max_length=20, unique=True, verbose_name='省份名称')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'province'
        verbose_name = '省份'
        verbose_name_plural = '省份'


class CityModel(models.Model):
    name = models.CharField(max_length=50, verbose_name='城市名称')
    province = models.ForeignKey(ProvinceModel,db_constraint=False, on_delete=models.DO_NOTHING, verbose_name='所属省份')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'city'
        verbose_name = '城市'
        verbose_name_plural = '城市'


class AreaModel(models.Model):
    name = models.CharField(max_length=50, verbose_name='区域名称')
    city = models.ForeignKey(CityModel, db_constraint=False, on_delete=models.DO_NOTHING, verbose_name='所属城市')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'area'
        verbose_name = '区域'
        verbose_name_plural = '区域'







